import React from "react";


function Function(props) {

    return (
        <div>
            第一个函数组件：{props.timer}
        </div>
    )
}


class FunctionTimer extends React.Component {
    state = {
        time: 0,
    }


    componentDidMount() {
       this.setTime = setInterval(() => {
            this.setState({time: this.state.time + 1})
        }, 1000);
    }

    componentWillUnmount() {
        clearInterval(this.setTime);
    }

    render() {
        const { time } = this.state;
        return (
            <Function timer={time} />
        );
    }
}

export default FunctionTimer;